//
//  UIImageView+BVWebCache.m
//  AFNetworking
//
//  Created by 崔晋 on 2019/8/11.
//

#import "UIImageView+BVWebCache.h"
#import "SDWebImage.h"

static NSString * const BV_RESOURCE_BASE_URL = @"https://obs.zheshi.tech/";

@implementation UIImageView (BVWebCache)

- (void)bv_imageWithUrl:(NSString *)urlStr {
    if (![urlStr hasPrefix:@"http"]) {
        urlStr = [NSString stringWithFormat:@"%@%@", BV_RESOURCE_BASE_URL, urlStr];
    }
    NSURL *url = [NSURL URLWithString:urlStr];
    [self sd_setImageWithURL:url];
}

- (void)bv_imageWithUrl:(NSString *)urlStr placeholderImage:(UIImage *)placeholderImage {
    if (![urlStr hasPrefix:@"http"]) {
        urlStr = [NSString stringWithFormat:@"%@%@", BV_RESOURCE_BASE_URL, urlStr];
    }
    NSURL *url = [NSURL URLWithString:urlStr];
    [self sd_setImageWithURL:url placeholderImage:placeholderImage];
}


@end
